package com.sense.kukoo.common.utils

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import com.sense.kukoo.lib_logger.LoggerManager

class ClipboardUtil {
    companion object{

        private val TAG: String = javaClass.simpleName

        fun copy(copy: String):Boolean{
            try {
                val clipboard = ApplicationContext.instance().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
                if (clipboard == null) {
                    LoggerManager.e(TAG, "clipboard == null")
                    return false
                } else {
                    val clip = ClipData.newPlainText("id", copy)
                    clipboard.setPrimaryClip(clip)
                    return true
                }
            }catch (e: Exception){
                e.printStackTrace()
                return false
            }
        }
    }
}